module: add module.entrypoint - #64903
Open
mcollina wants to merge 1 commit into
Open
Conversation
Add `module.entrypoint`, a property exposing the resolved URL of the entry point of the current thread. Unlike `require.main`, it works regardless of whether the entry point is a CommonJS or an ECMAScript module, and inside worker threads it reflects the entry point of the worker itself, matching the semantics of `require.main` and `import.meta.main`. Refs: nodejs#51840 Refs: nodejs#64800 Signed-off-by: Matteo Collina <hello@matteocollina.com>
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64903 +/- ##
==========================================
+ Coverage 90.13% 90.15% +0.01%
==========================================
Files 746 746
Lines 242893 242925 +32
Branches 45769 45777 +8
==========================================
+ Hits 218935 219006 +71
+ Misses 15444 15399 -45
- Partials 8514 8520 +6
🚀 New features to boost your workflow:
|
avivkeller
approved these changes
Aug 1, 2026
jasnell
approved these changes
Aug 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
module.entrypointtonode:module: the resolved URL string of the entry point of the current thread.The semantics follow
require.mainandimport.meta.main(thread-scoped): inside a worker thread it is the URL of the script the worker was started with, not the entry point of the process. This complements #64800, which exposes the process-wide entry point inherited by workers.undefinedfor--eval, the REPL, STDIN input, andeval: trueworkers; set to thedata:URL for data URL workers.--preserve-symlinks-main), so it matchesrequire.main.filename/ the entry point'simport.meta.urlrather thanprocess.argv[1].Refs: #51840
Refs: #64800